package com.csun.cmny.provider.dao;

import com.csun.cmny.provider.dto.Group;
import com.csun.cmny.provider.dto.NursingBindRoomDto;
import com.csun.cmny.provider.model.vo.OmcUserVo;
import com.csun.cmny.provider.pojo.NursingGroup;
import com.csun.cmny.provider.pojo.Room;
import com.csun.cmny.provider.pojo.User;
import com.csun.cmny.provider.vo.CountVo;
import com.csun.cmny.provider.vo.NurseHomeVo;
import com.csun.cmny.provider.vo.NursingGroupBind;
import com.csun.cmny.provider.vo.NursingGroupVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface GroupMapper extends Mapper<NursingGroup> {
    //通过id删除护工组
    int deleteById(Long groupId);

    int insert(Group record);

    //插入一个护工组
    int insertSelectiveByGroup(Group record);


    //通过护工组名称和机构id查询护工组信息
    List<NursingGroupVo> selectByName(Group group);

    //通过护工组名称和机构id查询护工组信息
    List<NursingGroupVo> selectListByName(Group group);

    //通过护工组名称和机构id查询护工组护工信息
    List<NursingGroupVo> selectNursingListByName(Group group);

    //通过护工组Id或者护工Id查询是否有绑定护工组
    List<NursingGroupBind> selectNursingGroupBind(Group group);


    //通过护工组的ID查询绑定的护工的ID集合
    List<Long> selectUserIdListById(@Param("nursingGroupId") Long nursingGroupId);

    //通过护工组ID或者楼栋ID查询楼栋房间集合
    List<Room> selectForBuilding(Group group);

    //通过groupId修改护工组信息
    int updateByIdSelective(Group record);

    //护工组绑定护工
    int insertNursingGroupBind(List<User> list);

    //护工组绑定房间
    int insertNursingRoomBind(List<Room> list);

    int updateById(Group record);

    //批量删除护工组绑定的房间
    int deleteNursingRoomBind(@Param("list") List<Room> list, @Param("nursingGroupId") Long nursingGroupId);

    //根据护工组ID查询被绑定的房间
    List<Room> selectNursingBindRoom(Long nursingGroupId);

    //根据绑定关系ID,护工组,护工ID删除绑定关系
    int deleteNursingGroupBind(Group group);

    //根据班组Id删除绑定的房间
    int deleteRoomBindById(Long nursingGroupId);

    //根据护工组的ID,删除绑定的护工
    int deleteUserBindById(Long nursingGroupId);

    //根据楼栋Id查询未被分配的房间
    List<Room> selectByBuildingId(Long buildingId);

    //根据userId查询nursingGroupId
    Long selectNuringGroupIdByUserId(@Param("userId") Long userId);

    //根据userId集合查询其中已绑定护工组的护工
    List<Long> selectNusringBindByList(@Param("list") List<Long> list);

    /**
     * 根据userId查询用户班组信息
     * @param: [userId]
     * @return: com.csun.cmny.provider.model.vo.OmcUserVo
     */
    OmcUserVo getUserNursingGroupInfo(@Param("userId") Long userId);

    /**
     * 查询班组排班计划待审批数量
     *
     * @param params
     *
     * @return
     */
    Map<Integer, Integer> queryNursingGroupNum(Map<String, Object> params);
    /*
     * 大数据平台健康占比亚健康展示
     * */
    NurseHomeVo selectByNursingHome(@Param("groupIdList") List<Long> groupIdList);

    //查询该品台下机构类别
    List<CountVo> selectType(@Param("groupIdList") List<Long> groupIdList);
    /**
     * 护工绑定房间
     */
    Integer nursingBindRoom(NursingBindRoomDto nursingBindRoomDto);

    void deleteByUserId(@Param("userIds") List<Long> userIds);
    //护工绑定护工组
    void nursingBindNursingGroup(NursingBindRoomDto nursingBindRoomDto);

    void deleteByNursingGroupId(NursingBindRoomDto nursingBindRoomDto);
}